package com.itqf.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @Description:   BeanPostProcessor  后置处理器
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/9/29
 * @Time: 下午2:33
 */
public class MyPostBeanProcessor implements BeanPostProcessor {

    /**
     * spring创建对象后   init方法前执行
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("前-----init"+beanName);
        return bean;
    }

    /**
     * init方法后执行
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("后-----init"+beanName);
        return bean;
    }
}
